<template>
  <div class="dialog">
    <div class="title">
      <div class="presuffix" />
      {{ props.title }}
      <img :src="icons.closeIcon" @click="close" class="close">
    </div>
    <div class="main">
      <video-player id="video" class="player" ref="video" />
    </div>
    <div class="bottom" />
  </div>
</template>

<script lang="ts" setup>
import { onMounted, ref } from 'vue'
import closeIcon from '@/assets/dialog/warn_close.svg'

const emit = defineEmits(['close'])
const icons = ref({
  closeIcon: closeIcon
})

const props = defineProps({
  title: {
    type: String,
    default: ''
  },
  url: {
    type: String,
    default: ''
  }
})

const video = ref()

const close = () => {
  emit('close')
}

onMounted(() => {
  // video.value = document.getElementById('video')
  // console.log('初始化播放器')
  // console.log(video.value)
  setTimeout(() => {
    video.value.play(props.url)
    console.log(props.url)
  }, 300)
})
</script>
<style lang="scss" scoped>
.dialog {
  border-radius: 5px;
  background: #1F2935;
  display: flex;
  flex-direction: column;

  .title {
    width: 100%;
    height: 40px;
    display: flex;
    align-items: center;
    color: #FFFFFF;
    font-size: 14px;
    background: #283442;

    .presuffix {
      width: 3px;
      height: 20px;
      border-radius: 0px 3px 3px 0px;
      background: #E6A23C;
      margin: 0 12px;
    }

    .close {
      width: 18px;
      height: 18px;
      margin-left: auto;
      margin-right: 12px;
      cursor: pointer;
    }
  }

  .main {
    width: 100%;
    height: 400px;
    margin-top: 20px;
    background-color: #1f2935;

    .player {
      width: 100%;
      height: 100%;
    }

    .video-left-icon {
      position: absolute;
      left: 0;
      top: 0;
      right: 0;
      bottom: 0;
    }
  }

  .bottom {
    width: 100%;
    height: 20px;
    margin-top: 10px;
    background: #283442;
  }
}
</style>
